package com.joymart.compute.repository;

import com.joymart.common.data.jdbc.BaseRepository;
import com.joymart.compute.model.SalesPv;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Repository
public interface SalesPvRepository extends BaseRepository<SalesPv,String> {

    @Query("select sum(amount) from sales_pv where owner_id = :ownerId and created_at between :start and :end")
    BigDecimal sumSalesPv(@Param("ownerId") String ownerId,
                          @Param("start") LocalDateTime start,
                          @Param("end") LocalDateTime end);
}
